package com.pengshun.modules.api.petrol.service.impl;

import com.pengshun.modules.api.mapper.PetrolStationMapper;
import com.pengshun.modules.api.petrol.service.PetrolStationService;
import com.pengshun.modules.api.petrol.service.dto.*;
import com.pengshun.modules.api.petrol.service.para.JyPetrolStationProductListPara;
import com.pengshun.modules.api.system.service.dto.Content;
import com.pengshun.modules.common.BaseResult;
import com.pengshun.modules.common.PagePara;
import com.pengshun.modules.domain.JyPetrolStation;
import com.pengshun.modules.domain.JyPetrolStationActivity;
import com.pengshun.modules.domain.JyPetrolStationGun;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author luoligang
 * @create 2021/6/28
 */
@Service
@AllArgsConstructor
public class PetrolStationServiceImpl  implements PetrolStationService {

    private final PetrolStationMapper petrolStationMapper;

    @Override
    public BaseResult list(PagePara page, JyPetrolStationProductListPara para) {
        List<JyPetrolStationProductListDto> list=petrolStationMapper.selectList(page.getPage(),page.getSize(),para.getName(),para.getBrandId(),para.getDistance(),para.getLatitude(),para.getLongitude(),para.getSort(),para.getStationId());
        return new BaseResult(0,list);
    }

    @Override
    public BaseResult detil( JyPetrolStationProductListPara para) {
        JyPetrolStationProductDetilDto detilDto=petrolStationMapper.selectDetilBy(para.getPetrolStationProductId(),para.getLongitude(),para.getLatitude());
        return new BaseResult(0,detilDto);
    }

    @Override
    public BaseResult condition() {
        List<JyPetrolStationConditionDto> list=petrolStationMapper.selectConditionList();
        List<JyPetrolStationConditionDto> nextDtoList=petrolStationMapper.selectConditionNextList();
        JyPetrolStationConditionDto dto=new JyPetrolStationConditionDto();
        dto.setCategoryName("全部");
        nextDtoList.add(0,dto);
        JyPetrolStationCondition condition=new JyPetrolStationCondition(list,nextDtoList);
        return new BaseResult(0,condition);
    }

    @Override
    public BaseResult type(JyPetrolStationProductListPara para) {
        List<JyPetrolStationTypeDto> list=petrolStationMapper.selectType(para.getPetrolStationId());
        return new BaseResult(0,list);
    }

    @Override
    public BaseResult guns(Long petrolStationProductId) {
        List<JyPetrolStationGun> list=petrolStationMapper.selectGuns(petrolStationProductId);
        List<JyPetrolStationActivity> aclist=petrolStationMapper.activityList(petrolStationProductId);
        ActivityDto dto=new ActivityDto(list,aclist);
        return new BaseResult(dto);
    }

}
